package com.framework.network.utils

import androidx.annotation.Keep
import com.google.gson.Gson

/**
 * @ClassName: ResultDataBean
 * @Description:
 * @Author: you
 */
@Keep
class ResultDataBean {
    var listDataBean: MutableList<Any>? = mutableListOf()

    /**
     * 数据转化
     */
    fun convertData(clas: MutableList<Class<*>>): MutableList<Any> {
        val listData = mutableListOf<Any>()
        if (listDataBean.isNullOrEmpty().not()) {
            val gson = Gson()
            listDataBean?.forEachIndexed { index, s ->
                val fromJson = if (index < clas.size) {
                    gson.fromJson(gson.toJson(s), clas[index])
                } else {
                    gson.toJson(s)
                }
                listData.add(fromJson)
            }
        }
        return listData
    }
}